package com.task.controller;

import com.task.common.util.body.JsonResult;
import com.task.common.util.body.ResultTool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Huzz
 * @created 2021-12-02 19:32
 */
@Api(tags = "权限使用说明")
@RestController
public class TestController {

    @ApiOperation("拥有query权限")
    @PreAuthorize("@ss.hasPermi('query')")
    @GetMapping("/test1")
    public JsonResult test1() {
        return ResultTool.success("拥有query权限");
    }

    @ApiOperation("拥有query:user权限")
    @PreAuthorize("@ss.hasPermi('query:user')")
    @GetMapping("/test2")
    public JsonResult test2() {
        return ResultTool.success("拥有query:user权限");
    }

    @ApiOperation("拥有add:user权限")
    @PreAuthorize("@ss.hasPermi('add:user')")
    @GetMapping("/test3")
    public JsonResult test3() {
        return ResultTool.success("拥有add:user权限");
    }

    @ApiOperation("拥有角色LOG")
    @PreAuthorize("@ss.hasAnyRoles('LOG')")
    @GetMapping("/test4")
    public JsonResult test4() {
        return ResultTool.success("拥有角色LOG");
    }
}
